package com.soup.lab.asserts;

/**
 * @author River
 */
public class Assertions {

    /*
        CharSequence
     */

    public static CharSequence requireNotNullOrEmpty(CharSequence cs, String message) {
        if(cs == null) {
            throw new NullPointerException(message);
        }
        if(cs.length() == 0) {
            throw new IllegalArgumentException(message);
        }
        return cs;
    }

    public static CharSequence requireNotNullOrBlank(CharSequence cs, String message) {
        if(cs == null) {
            throw new NullPointerException(message);
        }
        int strLen;
        if((strLen = cs.length()) > 0) {
            for (int i = 0; i < strLen; i++) {
                if(!Character.isWhitespace(cs.charAt(i))) {
                    return cs;
                }
            }
        }
        throw new IllegalArgumentException(message);
    }

}
